cmake_minimum_required(VERSION 2.8)

project(ua)

include(ExternalProject)
set(CMAKE_VERBOSE_MAKEFILE ON)

add_custom_target(third)

externalproject_add(
    deps_osip2
    PREFIX ${CMAKE_BINARY_DIR}/deps/
    URL ${CMAKE_SOURCE_DIR}/deps/libosip2-5.0.0.tar.gz
    CONFIGURE_COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/deps/
    BUILD_COMMAND make -j2
    BUILD_IN_SOURCE 1
    INSTALL_COMMAND make install
)
add_dependencies(third deps_osip2)

externalproject_add(
    deps_exosip2
    PREFIX ${CMAKE_BINARY_DIR}/deps/
    URL ${CMAKE_SOURCE_DIR}/deps/libexosip2-5.0.0.tar.gz
    CONFIGURE_COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/deps/
    BUILD_COMMAND make -j2
    BUILD_IN_SOURCE 1
    INSTALL_COMMAND make install
)
add_dependencies(deps_exosip2 deps_osip2)
add_dependencies(third deps_exosip2)

add_executable(${PROJECT_NAME} ua.c)
add_dependencies(${PROJECT_NAME} third)
target_link_libraries(${PROJECT_NAME} PUBLIC
    ${CMAKE_BINARY_DIR}/deps/lib/libeXosip2.a
    ${CMAKE_BINARY_DIR}/deps/lib/libosip2.a
    ${CMAKE_BINARY_DIR}/deps/lib/libosipparser2.a pthread ssl crypto resolv)
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_BINARY_DIR}/deps/include)
# target_link_directories(${PROJECT_NAME} PUBLIC ${CMAKE_BINARY_DIR}/deps/lib)
